package com.wudl.govern.controller;


import cn.hutool.core.bean.BeanUtil;
import cn.hutool.db.PageResult;
import com.github.pagehelper.PageInfo;
import com.wudl.common.api.CommonResult;
import com.wudl.govern.domain.entity.StandardTheme;
import com.wudl.govern.domain.vo.StandardThemeVO;
import com.wudl.govern.service.StandardThemeService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 标准主题 Service
 *
 * @author wudl
 */
@Api
@RestController
@RequestMapping("/standardTheme")
public class StandardThemeController {

    @Autowired
    private StandardThemeService standardThemeService;

    /**
     * 分页查询
     */
    @PostMapping("/page")
    public CommonResult<List<StandardTheme>> page(@RequestBody StandardThemeVO pageVO, @RequestParam Integer page, @RequestParam Integer size) {
        // 拷贝结果

    List<StandardTheme> page1 = standardThemeService.page(page, size);
        return CommonResult.success(page1);

    }

    /**
     * 查询详情
     */
    @GetMapping("/get/{id}")
    public CommonResult<StandardThemeVO> get(@PathVariable Object id) {
        StandardTheme entity = standardThemeService.getById(id);
        return CommonResult.success(BeanUtil.copyProperties(entity, StandardThemeVO.class));
    }

//    /**
//     * 新增
//     */
//    @PostMapping("/add")
//    public CommonResult<Void> add(@RequestBody StandardThemeVO addVO) {
//        standardThemeService.save(BeanUtil.copyProperties(addVO, StandardTheme.class));
//        return CommonResult.success();
//    }
//
//    /**
//     * 编辑
//     */
//    @PutMapping("/edit")
//    public CommonResult<Void> edit(@RequestBody StandardThemeVO editVO) {
//        standardThemeService.updateById(BeanUtil.copyProperties(editVO, StandardTheme.class));
//        return CommonResult.success();
//    }
//
//    /**
//     * 删除
//     */
//    @DeleteMapping("/delete/{id}")
//    public CommonResult<Void> delete(@PathVariable Object id) {
//        standardThemeService.removeById(id);
//        return CommonResult.success();
//    }

}
